package com.atguigu.lease.web.admin.controller.system;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.model.entity.SystemPost;
import com.atguigu.lease.model.base.BaseSearchDto;
import com.atguigu.lease.web.admin.service.SystemPostService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/system/post")
@Tag(name = "系统岗位管理模块")
public class SystemPostController {
    @Resource
    SystemPostService systemPostService;
    @Operation(summary = "分页查询岗位列表")
    @GetMapping("/page")
    public Result<Page<SystemPost>> page(BaseSearchDto searchDto){
        return Result.ok(systemPostService.page(searchDto.getPage(SystemPost.class)));
    }
    @Operation(summary = "新增或更新岗位")
    @PostMapping("/saveOrUpdate")
    public Result saveOrUpdate(@RequestBody SystemPost systemPost){
        return Result.build(systemPostService.saveOrUpdate(systemPost));
    }
    @Operation(summary = "查询所有岗位列表")
    @GetMapping("/list")
    public Result<List<SystemPost>> list(){
        return Result.ok(systemPostService.list());
    }
}
